package com.ydd.controller.admin;

import com.ydd.dto.PageSysRoleManagementDto;
import com.ydd.dto.SysRoleUpdateDto;
import com.ydd.result.Result;
import com.ydd.service.SysRoleManagementService;
import com.ydd.service.SysRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
@Slf4j
public class SysRoleManagementController {

    @Autowired
    SysRoleManagementService sysRoleManagementService;

    /**
     * 角色列表-分页
     * @param dto
     * @return
     */
    @GetMapping("/sys_role/list")
    public Result pageList(PageSysRoleManagementDto dto){
        log.info("用户列表:{}" , dto);
        return sysRoleManagementService.pageList(dto);
    }

    /**
     * 角色详情
     * @param id
     * @return
     */
    @GetMapping("/sys_role/rowInfo")
    public Result roleRowInfo(String id){
        log.info("角色详情:{}" , id);
        return sysRoleManagementService.roleRowInfo(id);
    }

    /**
     * 角色修改
     * @param dto
     * @return
     */
    @PostMapping("/sys_role/update")
    public Result update(@RequestBody SysRoleUpdateDto dto){
        log.info("角色修改:{}" , dto);
        return sysRoleManagementService.update(dto);
    }





    /**
     * 角色列表-全部
     * @return
     */
    @GetMapping("sys_role/allData")
    public Result allData(){
        log.info("角色列表-全部");
        return sysRoleManagementService.allData();
    }

    /**
     *
     * @param dto
     * @return
     */
    @PostMapping("/sys_role/add")
    public Result add(@RequestBody SysRoleUpdateDto dto){
        log.info(" 角色添加:{}",dto);
        return sysRoleManagementService.add(dto);
    }



    /**
     * 角色删除
     * @param id 传的是被修改人的role  id
     * @return
     */
    @PostMapping("/sys_role/del")
    public Result del(String id){
        log.info("角色详情:{}" , id);
        return sysRoleManagementService.del(id);
    }
}










